/*
 * @Author: cl
 * @Description:
 * @Date: 2023-04-18 16:04:08
 * @LastEditTime: 2023-05-04 17:16:15
 * @FilePath: \vue3\src\api\moudules\student.js
 * @LastEditors: cl
 */
import axios from "axios";
import { getToken } from "../../utils/auth";
axios.defaults.baseURL = "http://localhost:4000/api";


export const addStudent = (data) =>
  axios.post("/student/add", data).then((res) => res.data);

export const getList = (data) => {
    return new Promise((resolve,reject)=>{
        axios.defaults.headers.Authorization = `Bearer ${getToken()}`;
        axios.get("/student/findAll", { params: data }).then((res) => resolve(res.data))
    })
};

export const delStudent = (data) =>
  axios.delete(`/student/${data.id}`).then((res) => res.data);

export const updateStudent = (data) =>
  axios.patch(`/student/${data.id}`, data).then((res) => res.data);
//添加tag
export const addTags = (data) =>
  axios.post(`/user/add/tags`, data).then((res) => res.data);

export const addStuInfo = (data) =>
  axios.post("/student/addUserInfo", data).then((res) => res.data);

export const updateStuInfo = (data) =>
  axios
    .patch(`/student/updateUserInfo/${data.id}`, data)
    .then((res) => res.data);
